package br.com.fipsi.praticassgr.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.fipsi.praticassgr.banco.BaseDeDados;
import br.com.fipsi.praticassgr.model.Onibus;

/**
 * Servlet implementation class Adiciona
 */
@WebServlet("/Adiciona")
public class Adiciona extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Adiciona() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String modelo = request.getParameter("modelo");
		String assentos = request.getParameter("assentos");
		String chassi = request.getParameter("chassi");
		
		Onibus onibus = new Onibus();
		onibus.setChassi(chassi);
		onibus.setModeloDoVeiculo(modelo);
		onibus.setQntdAssentos(Integer.parseInt(assentos));
		BaseDeDados.lista.add(onibus);
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String modelo = request.getParameter("modelo");
		String assentos = request.getParameter("assentos");
		String chassi = request.getParameter("chassi");
		
		Onibus onibus = new Onibus();
		onibus.setChassi(chassi);
		onibus.setModeloDoVeiculo(modelo);
		onibus.setQntdAssentos(Integer.parseInt(assentos));
		BaseDeDados.lista.add(onibus);
	}

}
